#include <stdio.h>
#include <stdlib.h>

int main()
{
    int num, sum = 0;
    scanf("%d", &num);
    int * plist;
    plist = malloc(sizeof(int) * num);
    for(int i = 0; i < num; i++)
    {
        scanf("%d", plist+i);
        sum += *(plist+i);
    }
    printf("sum:%d\n", sum);
    scanf("%d", &num);
    plist = realloc(plist, num);
    sum = 0;
    for(int i = 0; i < num; i++)
    {
        sum += *(plist+i);
    }
    printf("sum:%d\n", sum);
    free(plist);
    return 0;
}